package com.heima.comment.controller.v1;

import com.heima.comment.service.ICommentReplyService;
import com.heima.comment.service.ICommentService;
import com.heima.model.comment.dtos.*;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "文章评论回复 API")
@RestController
@RequestMapping("api/v1/comment_repay")
public class CommentReplyController {

    @Autowired
    private ICommentReplyService commentReplyService;

    @ApiOperation(value = "文章评论下发表回复", notes = "文章评论下发表回复")
    @PostMapping("save")
    public ResponseResult saveCommentReply(@RequestBody @Validated CommentReplySaveDTO commentReplySaveDTO){
        return commentReplyService.saveCommentReply(commentReplySaveDTO);
    }

    @ApiOperation(value = "文章下评论点赞", notes = "文章下评论点赞")
    @PostMapping("like")
    public ResponseResult handleLike(@RequestBody @Validated CommentReplyLikeDTO commentReplyLikeDTO){
        return commentReplyService.handleLike(commentReplyLikeDTO);
    }

    @ApiOperation(value = "查询文章评论列表", notes = "查询文章评论列表")
    @PostMapping("load")
    public ResponseResult listCommentReply(@RequestBody @Validated CommentReplyQueryDTO commentReplyQueryDTO){
        return commentReplyService.listCommentReply(commentReplyQueryDTO);
    }
}
